import 'package:flutter/material.dart';
import 'package:flutter_demo/helpers.dart';
import 'package:flutter_demo/widgets/menu.widget.dart';
import 'package:flutter_demo/widgets/tab.widget.dart';
import 'package:flutter_demo/pages/activity/list.page.dart';
import 'package:flutter_demo/pages/profile/profile.page.dart';

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new _HomePageState();
  }
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {

    final List<String> tabs = <String>['活动列表', '我'];

    final List<Widget> widgets = <Widget>[
      new ActivityListPage(),
      new ProfilePage()
    ];

    const List<Menu> menus = const <Menu>[
      const Menu(title: 'item 1', icon: Icons.add),
      const Menu(title: 'item 2', icon: Icons.add),
      const Menu(title: 'item 3', icon: Icons.add),
    ];

    return new TabbedScaffold(
      title: '团子',
      tabs: tabs,
      actions: <Widget>[
        new IconButton(
          icon: const Icon(
            Icons.search,
            color: Colors.white,
          ),
          tooltip: 'more',
          onPressed: () {},
        ),
        new PopupMenuButton<Menu>(
          itemBuilder: (BuildContext context) {
            return menus.skip(0).map((Menu menu) {
              return new PopupMenuItem<Menu>(
                value: menu,
                child: new Text(menu.title),
              );
            }).toList();
          },
        ),
      ],
      widgets: widgets,
    );
  }
}